package MultiThread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class CallableThread {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<String> task = new FutureTask<>(new MyCallable());
        Thread myThread = new Thread(task);
        myThread.start();
        String msg = task.get();
        System.out.println(msg);
    }
}

class MyCallable implements Callable<String> {
    @Override
    public String call() throws Exception {
        // 代码逻辑
        return "返回什么类型，就在接口泛型和call返回值类型中改成什么类型即可";
    }
}